package com.meida.app.provider.listener;

import com.meida.app.provider.integration.authenticator.sms.event.SmsAuthenticateBeforeEvent;
import com.meida.module.user.provider.service.AppAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * @author zyf
 */
@Component
public class UserInfoListener {
    @Autowired
    private AppAccountService appAccountService;

    /**
     * 手机号验证码登录自动注册监听
     */
    @EventListener
    public void smsLoginEvent(SmsAuthenticateBeforeEvent userInfoEvent) {
        String accountName = userInfoEvent.getAccountName();
        String password = userInfoEvent.getPassword();
        appAccountService.registerByMobile(accountName, password);
    }
}
